from flask import Flask,json
from . import mesh

def create_app(test_config=None):
    app = Flask(__name__, instance_relative_config=True)
    app.config.from_mapping(
        SECRET_KEY='dev',
    )
    #print("SECRET_KEY",app.config['SECRET_KEY'])
    app.logger.warning("app log warning test")
    
    if test_config is None:
        app.config.from_pyfile('config.py', silent=True)
        print("if")
    else:
        app.config.from_mapping(test_config)
        print("else")

    from . import mesh
    app.register_blueprint(mesh.meshbp)

    from . import group
    app.register_blueprint(group.bp)

    from . import light
    app.register_blueprint(light.bp)

    from . import controller
    app.register_blueprint(controller.bp)

    from . import grant
    app.register_blueprint(grant.bp)

    from . import error
    app.register_blueprint(error.errorbp)

    return app

